package test.service;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ServiceActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
	private static final String TAG = "ServicesDemo";
	Button buttonStart, buttonStop;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        buttonStart = (Button) findViewById(R.id.button1);
        buttonStop = (Button) findViewById(R.id.button2);
        
        buttonStart.setOnClickListener(this);
        buttonStop.setOnClickListener(this);
    }
    
    public void onClick(View src) {
    	switch( src.getId()) {
    	case R.id.button1:
    		Log.d(TAG, "onClick starting srvice");
    		startService(new Intent(this, MyService.class));
    		break;
    	case R.id.button2:
    		Log.d(TAG, "onClick: stopping srvice");
    		stopService(new Intent(this, MyService.class));
    		break;
    	}
    }
}